package com.example.demo.service.impl;

import com.example.demo.dao.LecturerDao;
import com.example.demo.entity.LecturerBean;
import com.example.demo.service.LecturerService;
import com.example.demo.util.PageEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LecturerServiceImpl implements LecturerService {
    @Autowired
    private LecturerDao lecturerDao;

    @Override
    public Integer add(LecturerBean lecturerBean) {
        return lecturerDao.add(lecturerBean);
    }

    @Override
    public Integer update(LecturerBean lecturerBean) {
        return lecturerDao.update(lecturerBean);
    }

    @Override
    public Integer delete(Integer id) {
        return lecturerDao.delete(id);
    }

    @Override
    public LecturerBean one(Integer id) {
        return lecturerDao.getOneById(id);
    }

    @Override
    public PageEntity list(Integer pageNo, Integer pageSize, String name, String sortOrder) {
        Integer count = lecturerDao.count(name);
        List<LecturerBean> list = lecturerDao.list(name, sortOrder);
        return new PageEntity<>(list, count);
    }
} 